package com.kaishengit.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.kaishengit.entity.Employee;
import com.kaishengit.entity.Message;
import com.kaishengit.service.MessageService;


public class MessageServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String message = request.getParameter("message");
		String proId = request.getParameter("proId");
		
		HttpSession session = request.getSession();
		Employee em = (Employee) session.getAttribute("loginUser");
		MessageService msgService = new MessageService();
		msgService.addMsg(message, proId, em);
		
		List<Message> msgList = msgService.findMsg(proId);
		session.setAttribute("myMsgList", msgList);
		
		request.getRequestDispatcher("WEB-INF/views/project.jsp").forward(request, response);
	}

}
